import { WeaRightMenu, WeaTop, WeaLeftRightLayout,WeaLocaleProvider } from 'ecCom';
import { Button } from 'antd';
import { observer, inject } from 'mobx-react';
import TemplateList from './TemplateList';
import TemplateGroupList from './TemplateGroupList';
const getLabel = WeaLocaleProvider.getLabel;

import './index.less';
import AddExcelTemplateDialog from '../dialog/addExcelTemplate';
@inject('edcPathTemplateStore')
@observer
export default class PathTemplate extends React.Component {
    componentDidMount() {
        const { edcPathTemplateStore: store } = this.props;
        store.init();
    }
    render() {
        const { edcPathTemplateStore: store } = this.props;
        const { addExcelTemplateStore } = store;
        const menu = [{
            key: '1',
            icon: <i className='icon-coms-search' />,
            content: getLabel(388113,'搜索'),
            onClick: store.search,
        }, {
            key: '2',
            icon: <i className='icon-coms-New-Flow' />,
            content: getLabel(365,'新建'),
            onClick: store.create,
        }, {
            key: '3',
            icon: <i className='icon-coms-delete' />,
            content: getLabel(502286,'删除'),
            onClick: store.delete,
            disabled: store.deleteDiabled
        }];
        const btns = [<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@sxfhet@create`} type="primary" onClick={store.create}>{getLabel(365,'新建')}</Button>,
        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@7eoa0a@delete`} type="primary" disabled={store.deleteDiabled} onClick={store.delete}>{getLabel(502286,'删除')}</Button>];
        return (
            <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@53xowv`} datas={menu} >
                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@4oojdm`}
                    title={getLabel('502754','路径模板管理')}
                    iconBgcolor="#1a57a0"
                    icon={<i className="icon-coms02-Data-center" />}
                    showDropIcon={true}
                    dropMenuDatas={menu}
                    loading={store.tableStore.loading}
                    buttons={btns}
                >
                    <WeaLeftRightLayout ecId={`${this && this.props && this.props.ecId || ''}_WeaLeftRightLayout@o3dk6h`}
                        leftWidth={300}
                        leftCom={<TemplateGroupList ecId={`${this && this.props && this.props.ecId || ''}_TemplateGroupList@7t0sm2`} store={store} />}
                    >
                        <TemplateList ecId={`${this && this.props && this.props.ecId || ''}_TemplateList@gjuc9h`} store={store} />
                    </WeaLeftRightLayout>
                </WeaTop>
                {addExcelTemplateStore.visible && <AddExcelTemplateDialog ecId={`${this && this.props && this.props.ecId || ''}_AddExcelTemplateDialog@6dn7w1`} store={addExcelTemplateStore} />}
            </WeaRightMenu>
        )
    }
}